function InitToolbar()
{
	var buttons = document.body.getElementsByClassName("toolbar_button");

	for(var i = 0; i < buttons.length; i++)
	{
		buttons[i].addEventListener("mouseout", onBtnMouseOut, true);
		buttons[i].addEventListener("mousedown",onBtnMouseDown, true);
		buttons[i].addEventListener("click", onBtnMouseClick, true);
	}
}

function onBtnMouseDown(e)
{
	e.currentTarget.style.background = "#EEC67E";

	e.stopPropagation();
	e.preventDefault();
}

function onBtnMouseOut(e)
{
	if(e.target != e.currentTarget) return false;
	if(e.toElement == e.target.children[0]) return false;

	e.currentTarget.style.background = "none";
}

function onBtnMouseClick(e)
{
	e.currentTarget.style.background = "none";

	var cmd = e.currentTarget.getAttribute("cmd");
	var v = e.currentTarget.getAttribute("cmdValue");
	output(v);
	
	if(v == "null") v = null;
	else if( v == "prompt") v = prompt("Need the details: ");

	document.execCommand(cmd, false, v);
}